-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhancement: RateLimitFilter - Provides an exact rate limiting mechanism #794
base: main
Are you sure you want to change the base?
Conversation
you need exact rate limiting and can accept a small decrease in efficiency, ExactRateLimiter may be an alternative option.
minimize API change. |
You can't remove methods from the |
RateLimiter: keep api as stable as possible.
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR makes a very large number of unnecessary changes which makes it extremely hard to review. I have already spend multiple hours just reviewing the refactoring of TimeBucketCounter
.
I have yet to decide whether I will proceed with applying those changes as a first step towards to implementing the changes proposed in this PR or whether I'll opt to close this PR and request a series of smaller PRs where each PR addresses a single concern and, potentially, breaks larger, related changes into a series of smaller, reviewable commits.
public void periodicEvict() { | ||
final long minBucketIndex = getBucketIndex(System.currentTimeMillis()); | ||
// assume that elapsed time of periodicEvict less than 1x bucketDuration. | ||
// to avoid extreme case: 999999-xxx vs 1000000-xxx | ||
final long maxBucket = minBucketIndex + 2; | ||
|
||
final String minBucketPrefix = minBucketIndex + BUCKET_KEY_DELIMITER; | ||
final String maxBucketPrefix = maxBucket + BUCKET_KEY_DELIMITER; | ||
|
||
// remove obsolete items whose key are less than minBucketPrefix and maxBucketPrefix in same time. | ||
map.keySet().removeIf(k -> k.compareTo(minBucketPrefix) < 0 && k.compareTo(maxBucketPrefix) < 0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What problem is the change to the eviction mean to solve?
This is preparatory work for PR #794
It turns out the |
This is preparatory work for PR #794
This is preparatory work for PR #794
This is preparatory work for PR #794
smaller PR from #767 .
If you need exact rate limiting and can accept a small decrease in efficiency, ExactRateLimiter may be an alternative option.